@layout("/common/container.html", {bodyAttr:"background=\"/ds/images/background.svg\" style=\"background-size: cover;\"", css: ["/ds/css/other/login.css"]}) {
<form class="layui-form">
    <div class="layui-form-item">
        <img class="logo" src="/ds/images/logo.png"/>
        <div class="title">Distribution Sale</div>
        <div class="desc">
            微服务架构下的分销解决方案
        </div>
    </div>
    <div class="layui-form-item">
        <select id="platformUsernameSelect" name="platformUsername">
            <!-- 故意值写成了 空白字符串 这样select组件的字体颜色才是黑色 -->
            <option value=" ">平 台</option>
        </select>
    </div>
    <div class="layui-form-item">
        <input name="username" placeholder="账 户" lay-verify="required" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input name="password" placeholder="密 码" type="password" lay-verify="required" hover class="layui-input"/>
    </div>
    <!--    <div class="layui-form-item">-->
    <!--        <input placeholder="验证码" hover lay-verify="required" class="code layui-input layui-input-inline"/>-->
    <!--        <img src="/static/admin/images/captcha.gif" class="codeImage"/>-->
    <!--    </div>-->
    <!--    <div class="layui-form-item">-->
    <!--        <input type="checkbox" name="" title="记住密码" lay-skin="primary" checked>-->
    <!--    </div>-->
    <div class="layui-form-item">
        <button type="submit" class="pear-btn pear-btn-success login" lay-submit lay-filter="*">
            登 入
        </button>
    </div>
</form>
<script>
    layui.use(['form', 'popup', 'easyHttp'], function () {
        let form = layui.form;
        let popup = layui.popup;
        let easyHttp = layui.easyHttp;
        let $ = layui.$;

        // 所有平台
        easyHttp.execute({url: '/admin/platform/optional/list', method: 'GET'}, function (resp) {
            let $platformUsernameSelect = $('#platformUsernameSelect');
            for (let i = 0; i < resp.data.length; i++) {
                let p = resp.data[i];
                $platformUsernameSelect.append("<option value='" + p.username + "'>" + p.nickname + "</option>");
            }
            form.render('select');
        });

        // 登 录 提 交
        form.on('submit(*)', function (data) {
            easyHttp.execute({url: '/admin/login', method: 'POST', data: JSON.stringify(data.field)}, function (resp) {
                JwtOperator.setJwt(resp.data)
                popup.success('登录成功', function () {
                    window.location.href = '/';
                });
            });
            return false;
        });

    })
</script>
@}
